﻿using System;
using WaitLess.Business.Data.Foursquare.Interfaces;
using WaitLess.Business.Data.Model.Foursquare.HereNowResponse;
using WaitLess.Business.Data.Model.Foursquare.VenuesResponse;
using WaitLess.Business.Data.Web.Interfaces;
using WaitLess.Business.Repositories.Interfaces;

namespace WaitLess.Business.Repositories
{
    public class VenuesRepository : IVenuesRepository
    {
        private readonly IFoursquareContext _fourSquareContext;

        public VenuesRepository(IFoursquareContext fourSquareContext)
        {
            if (fourSquareContext == null) throw new ArgumentNullException("fourSquareContext");

            _fourSquareContext = fourSquareContext;
        }

        public void GetByName(string name, Action<VenuesResponse> receiveResult)
        {
            if (string.IsNullOrWhiteSpace(name)) throw new ArgumentNullException("query");
            if (receiveResult == null) throw new ArgumentNullException("receiveResult");

            _fourSquareContext.Venues(name, receiveResult);
        }

        public void GetHereNow(string venueId, string accessToken, Action<HereNowResponse> receiveResult)
        {
            if (string.IsNullOrWhiteSpace(venueId)) throw new ArgumentNullException("venueId");
            if (string.IsNullOrWhiteSpace(accessToken)) throw new ArgumentNullException("accessToken");

            _fourSquareContext.HereNow(venueId, accessToken, receiveResult);
        }
    }
}